package  
{
	import com.bumpslide.events.DragEvent;
	import com.bumpslide.tween.FTween;
	import com.bumpslide.ui.Applet;
	import com.bumpslide.ui.Box;
	import com.bumpslide.ui.behavior.DragBehavior;

	/**
	 * Drag Example 3 - Custom Drag
	 * 
	 * This example demonstrates custom dragging.  This is where we don't actually
	 * move the drag target with the DragBehavior, but we use the drag events to 
	 * do some custom motion.  In this case, we are applying a springing ease with FTween.
	 * 
	 * @author David Knape
	 * @mxmlc -sp+=../../classes -default-background-color 0xeeeeee -default-frame-rate 60 -debug=true
	 */
	public class DragExample03 extends Applet 
	{

		private var box:Box;
		
		override protected function addChildren():void
		{
			super.addChildren();

			box = new Box(0x000088, 100, 100, 100, 100, 0, 0, 0x000088);
			box.fillAlpha = .7;
			box.roundedPosition = false;
			box.buttonMode = true;
			addChild(box);			
			
			// make the box draggable, but don't have the DragBehavior do the moving
			// we will do this ourselves
			DragBehavior.init(box, null, false);
			
			// listen for drag move events
			addEventListener( DragEvent.EVENT_DRAG_MOVE, handleDrag);
		}
		
		
		private function handleDrag(event:DragEvent):void
		{
			FTween.spring( box, 'x', event.current.x );			FTween.spring( box, 'y', event.current.y );
		}

		
	}
}
